<?php

namespace App\Http\Middleware;

use App\Models\LoanApply;
use App\Models\RepaySummary;
use App\Models\User;
use App\Models\UserGlobal;
use App\Models\UserLoanRequest;
use Closure;

class CheckCanLoan
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = $request->user();
        /**
         * @var $user User
         */
        if(!$user->canLoan()){
            return failed('您有在途的业务');
        }
        return $next($request);
    }
}
